import { _decorator, Component, Node, Mask, Rect, UITransform, v3 } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('guideMask')
export class guideMask extends Component {
    private _uiMask: Mask;

    onLoad() {
        this._uiMask = this.getComponent(Mask);
    }

    //挖孔
    public digRect(rect: Rect) {
        this._uiMask.type = Mask.Type.GRAPHICS_RECT;
        this._uiMask.inverted = true;

        var trans = this._uiMask.getComponent(UITransform);
        var pos = trans.convertToNodeSpaceAR(v3(rect.x, rect.y));
        this._uiMask.node.setPosition(pos);
        trans.width = rect.width;
        trans.height = rect.height;
    }
}


